import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import dashboard from '../views/dashboard/index'
import channel from '../views/novelSystem/channel/index'
import classification from '../views/novelSystem/classification'
import label from '../views/novelSystem/label'
import banner from '../views/client/banner/index'
import base_config from '../views/client/base_config'
import book_list from '../views/client/book_list'
import comment from '../views/client/comment/index'
import guidance from '../views/client/guidance'
import nav from '../views/client/nav'
import user from '../views/client/user'
import article from '../views/novel/article'
import examine from '../views/novel/examine'
import signed from '../views/sign/signed'
import waitSign from '../views/sign/waitSign'
import rewardRules from '../views/signIn/rewardRules'
import voucher from '../views/signIn/voucher'
import dict from '../views/system/dict'
import sysNav from '../views/system/nav'
import sysUser from '../views/system/user'
/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    role: ['admin','editor']     will control the page role (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if fasle ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index') },
  { path: '/authredirect', component: _import('login/authredirect') },
  { path: '/404', component: _import('errorPage/404') },
  { path: '/401', component: _import('errorPage/401') }
]

const router=new Router({
   mode: 'hash', //后端支持可开
  // scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
export const asyncRouterMap=[
  {
    path: '/', // 路由地址
    component: Layout, // 所加载的组件或组件地址
    redirect: 'dashboard', // 是否重定向
    children: [{ //子组件
      path: 'dashboard',
      component: dashboard, //这个就返回组件的名称
      name: 'dashboard', //组件名称
      meta: { title: '首页'} //组件meta信息
    }]
  },
  {
    path:"/novelSystem",name:'novelSystem',meta:{icon:"home",title:"小说配置管理"},component: Layout, redirect: 'channel',
    children:[
      {path:"channel",component: channel,name:'channel',meta:{icon:"home",title:"频道管理"}},
      {path:"classification",component: classification,name:'classification',meta:{icon:"home",title:"分类管理"}},
      {path:"label",component: label,name:'label',meta:{icon:"home",title:"标签管理"}}
    ]
  },
  {
    path:"/novel",name:'novel',meta:{icon:"home",title:"小说管理"},component: Layout,redirect: 'examine',
    children:[
      {path:"examine",component: examine,name:'examine',meta:{icon:"home",title:"审核管理"}},
      {path:"article",component: article ,name:'article',meta:{icon:"home",title:"小说资源管理"}},
    ]
  },
  {
    path:"/client",name:'client',meta:{icon:"home",title:"客户端管理"},component: Layout,redirect: 'user',
    children:[
      {path:"user",component: user,name:'user',meta:{icon:"home",title:"用户管理"}},
      {path:"comment",component:comment,name:'comment',meta:{icon:"home",title:"评论管理"}},
      {path:"book_list",component:book_list,name:'book_list',meta:{icon:"home",title:"书单管理"}},
      {path:"banner",component: banner,name:'banner',meta:{icon:"home",title:"轮播管理"}},
      {path:"nav",component: nav,name:'nav',meta:{icon:"home",title:"导航管理"}},
      {path:"guidance",component: guidance,name:'guidance',meta:{icon:"home",title:"指导管理"}},
      {path:"base_configure",component: base_config,name:'base_configure',meta:{icon:"home",title:"基本配置"}}
    ]
  },
  {
    path:"/sign",name:'sign',meta:{icon:"home",title:"签约管理"},component: Layout,redirect: 'base_configure',redirect: 'waitSign',
    children:[
      {path:"waitSign",component: waitSign,name:'waitSign',meta:{icon:"home",title:"待签约管理"}},
      {path:"signed",component: signed,name:'signed',meta:{icon:"home",title:"已签约管理"}}
    ]
  },
  {
    path:"/signIn",name:'signIn',meta:{icon:"home",title:"签到系统"},component: Layout,redirect: 'voucher',
    children:[
      {path:"voucher",component: voucher,name:'voucher',meta:{icon:"home",title:"代金券管理"}},
      {path:"rewardRules",component: rewardRules,name:'rewardRules',meta:{icon:"home",title:"规则管理"}}
    ]
  },
  {
    path:"/system",name:'system',meta:{icon:"home",title:"系统管理"},component: Layout,redirect: 'voucher',
    children:[
      {path:"user",component: sysUser,name:'user',meta:{icon:"home",title:"用户管理"}},
      {path:"dict",component: dict,name:'dict',meta:{icon:"home",title:"数据字典"}},
      {path:"nav",component: sysNav,name:'nav',meta:{icon:"home",title:"导航管理"}},
    ]
  },
  { path: '*', redirect: '/404' }
]
export default  router
